<?php

namespace App\Http\Controllers\Admin;

use App\Enums\NoticeType;
use App\Http\Controllers\Controller;
use App\Models\ActiveRuleOline;
use App\Models\ActiveRuleQd;
use App\Models\Game\ActiveAtrr;
use App\Models\Game\ActiveCode;
use App\Models\Game\ActiveRule;
use App\Models\Game\CashMonitor;
use App\Models\Game\ConfigGroup;
use App\Models\Game\Equip;
use App\Models\Game\EquipAttr;
use App\Models\Game\EquipConfig;
use App\Models\Game\EquipNeedMonitor;
use App\Models\Game\EquipNeedRecord;
use App\Models\Game\GameChannel;
use App\Models\Game\GameGoods;
use App\Models\Game\GameMallGoods;
use App\Models\Game\GameMallGoodsconfg;
use App\Models\Game\GameVersion;
use App\Models\Game\GemList;
use App\Models\Game\Map;
use App\Models\Game\OperType;
use App\Models\Game\PackageChannel;
use App\Models\Game\PetAttr;
use App\Models\Game\PetConfig;
use App\Models\Game\PetSkill;
use App\Models\Game\ServerGroup;
use App\Models\Game\SoulSkill;
use App\Models\Game\SoulTalent;
use App\Models\Game\Task;
use App\Utils\MyLog;
use App\Utils\ResponseUtil;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\DB;


class EnumController extends Controller
{
    private Request $request;

    /**
     * EnumController constructor.
     */
    public function __construct(Request $request)
    {
        $this->request = $request;

    }

    public function list(){

        $admin = Auth::guard('admin')->user();
        //获取登录用户的分配服务器分组权限
        $groups_ids = $admin['groups_ids'];

        $groups_ids_array = explode(",", $groups_ids);
        //查看渠道分组是那个
        //查看分组渠道名
        $type = ServerGroup::query()
            ->select('type')
            ->whereIn('id', $groups_ids_array)
            ->get()
            ->pluck('type')
            ->toArray();
        if (in_array('qqgame', $type)&& count($type) === 1) {
            $channel=GameChannel::query()->where('id',10)->get();
            $groups=  ServerGroup::whereIn('id',$groups_ids_array)->get();
            $payChannel = [
                [
                    'id' => 'qq',
                    'name' => 'QQ大厅'
                ]
            ];
        }else if(in_array('qingyi', $type)&& count($type) === 1){
            $channel=GameChannel::query()->where('id',12)->get();
            $groups=  ServerGroup::whereIn('id',$groups_ids_array)->get();
            $payChannel = null;
        }
        else{
            $payChannel = [
                [
                    'id' => 'quickgame',
                    'name' => 'quickgame'
                ],
                [
                    'id' => 'quickgameB',
                    'name' => 'quickgameB'
                ],
                [
                    'id' => 'mmoppo',
                    'name' => 'oppo'
                ],
                [
                    'id' => 'mmvivo',
                    'name' => 'mmvivo'
                ],
                [
                    'id' => 'mmdangle',
                    'name' => '当乐'
                ],
                [
                    'id' => 'mmxiaomi',
                    'name' => '小米'
                ],
                [
                    'id' => 'mmhonor',
                    'name' => '荣耀'
                ],
                [
                    'id' => 'mmhuawei',
                    'name' => '华为'
                ],
                [
                    'id' => 'mmleidian',
                    'name' => '雷电'
                ],
                [
                    'id' => 'mmjiuyou',
                    'name' => '九游'
                ],
                [
                    'id' => 'mmguopan',
                    'name' => '果盘'
                ],
                [
                    'id' => 'mmmeizu',
                    'name' => '魅族'
                ],
                [
                    'id' => 'mm4399',
                    'name' => '4399'
                ],
                [
                    'id' => 'mmmumu',
                    'name' => 'mumu模拟器'
                ],
                [
                    'id' => 'mmlenovo',
                    'name' => '联想'
                ]
            ];
            $channel=GameChannel::query()->get();
            $groups=  ServerGroup::query()->get();

        }

        $groups = ServerGroup::with('servers')->get();

        $groups = $groups->map(function ($group) {
            return [
                'group_id' => $group->id,
                'group_name' => $group->name,
                'server_ids' => $group->servers->pluck('server_id')->toArray(), // 获取对应的 server_id
            ];
        });

        $data = [
            'noticeType'=>NoticeType::map(),
            'map'=>Map::query()->select('id','name')->get(),
            'operType'=>OperType::query()->select('id','name')->get(),
            'equip'=>Equip::query()->select('id','name','ItemQuality')->get(),
            'equipconfig'=>EquipConfig::query()->select('id','name','ItemQuality','level')->get(),
            'petconfig'=>PetConfig::query()->select('id','name','ItemQuality','pid')->get(),
            'equip_monitor_ids'=>EquipNeedMonitor::query()->pluck('equip_id')->toArray(),
            'equipAttr'=>EquipAttr::query()->select('id','name')->get(),
            'gemList'=>GemList::query()->get(),
            'soulTalent'=>SoulTalent::query()->get(),
            'soulSkill'=>SoulSkill::query()->get(),
            'petAttr'=>PetAttr::query()->get(),
            'petSkill'=>PetSkill::query()->get(),
            'gameGoods'=>GameGoods::query()->get(),
            'serverGroup'=>$groups,
            'channel'=>$channel,
            'packagechannels'=>PackageChannel::query()->select('id','name','nick')->get(),
            'payChannel'=>$payChannel,
            'activeatrr'=>ActiveAtrr::query()->select('id','name')->get(),
            'configgroup'=>ConfigGroup::query()->select('id','name','type')->get(),
            'gameVersion'=>GameVersion::query()->select('id','name','mark')->get(),

            'gamemalllist'=>GameMallGoodsconfg::query()->select('id','name','shopmallId')->get(),


        ];
        return ResponseUtil::success($data);
    }

    public function import(){ //excel导入
        $data = $this->request->all();
        $name = data_get($data,'name');
        $table = data_get($data,'table');
        $channeltype= data_get($data,'channeltype');
        $type= data_get($data,'type');

        $file = $this->request->file('file');
        $sheets = Excel::toArray(null,$file);
        if($table=='any'){
            return $this->any($sheets[0]);
        }
        if ($file->getClientOriginalName() !== $name) {
            return ResponseUtil::error("请上传: " . $name);
        }
        if (!in_array($table,['equip','map','oper_type','equip_attr','gem_list','game_goods','equip_monitor_limit',
        'soul_talent' ,'soul_skill', 'pet_attr', 'pet_skill','cashMonitor','game_goods_qq','game_goods_bt','game_goods_type',
            'activelist','activelistqd','activeatrrlist','activeCodelist','equipconfig','petconfig','task','gamemalllist'
        ])) return ResponseUtil::error("非法操作");

        if ($table==="equip") {
            return $this->importEquip($sheets[0]);
        }
        if ($table==="equipconfig") {
            return $this->importEquipConfig($sheets[0]);
        }
        if ($table==="petconfig") {
            return $this->importPetConfig($sheets[0]);
        }
        else if($table =="map"){
            return $this->importMap($sheets[0]);
        } else if($table =="oper_type"){
            return $this->importOperType($sheets[0]);
        } else if($table =="equip_attr"){
            return $this->importEquipAttr($sheets[0]);
        } else if($table == 'gem_list') {
            return $this->importGemList($sheets[0]);
        }
        else if($table == 'task'){

            return $this->importTask($sheets[0]);
        }
        else if($table == 'game_goods'){
            return $this->importGameGoods($sheets[0]);
        } else if($table =='equip_monitor_limit') {
            $this->importEquipNeedRecord($sheets[0]);
            $this->importEquipNeedMonitor($sheets[0]);
            return ResponseUtil::success();
        } else if($table == 'soul_talent'){

            return $this->importSoulTalent($sheets[0]);
        } else if($table == 'soul_skill'){

            return $this->importSoulSkill($sheets[0]);
        } else if($table == 'pet_attr'){

            return $this->importPetAttr($sheets[0]);
        } else if($table == 'pet_skill'){

            return $this->importPetSkill($sheets[0]);
        }
        else if($table == 'cashMonitor'){

            return $this->importcashMonitor($sheets[0]);
        }

        else if($table == 'activelist'){

            return $this->importActivelist($sheets[0]);
        }
        else if($table == 'activelistqd'){

            return $this->importActivelistqd($sheets[0]);
        }
        else if($table == 'activeatrrlist'){

            return $this->importActiveAtrrlist($sheets[0]);
        }
        else if($table == 'activeCodelist'){

            return $this->importActiveCode($sheets[0]);
        }
        //qq游戏大厅
        else if($table == 'game_goods_qq'){

            return $this->importGameGoodsQQ($sheets[0]);
        }
        //
        else if($table == 'game_goods_type'){

            return $this->importGameGoodsbt($sheets[0],$type);
        }
        else if($table == 'gamemalllist'){

            return $this->importGameMallGoods($sheets[0],$type);
        }
        return ResponseUtil::success();
    }

    private function importSoulTalent($sheet){ // 魂魄天赋
        SoulTalent::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                ];
                $data[] = $row;
            }
        }
        SoulTalent::query()->insert($data);
        return ResponseUtil::success();
    }
    private function importSoulSkill($sheet){ //魂魄技能

        SoulSkill::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                ];
                $data[] = $row;
            }
        }
        SoulSkill::query()->insert($data);
        return ResponseUtil::success();

    }
    private function importPetAttr($sheet){ //宠物属性

        PetAttr::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                ];
                $data[] = $row;
            }
        }
        PetAttr::query()->insert($data);
        return ResponseUtil::success();
    }

    private function importPetSkill($sheet){ //宠物技能

        PetSkill::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3 && !empty($arr[1]) && !empty($arr[3])){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[3],
                ];
                $data[] = $row;
            }
        }
        PetSkill::query()->insert($data);
        return ResponseUtil::success();

    }


    private function importcashMonitor($sheet){ //宠物技能

        CashMonitor::query()->truncate();
        $data = [];
        MyLog::info('saa'.json_encode($sheet));
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>0){
                if (isset($arr[1]) && empty($arr[1])) continue;
                $row = [
                    'name'=>$arr[0],
                    'itemId'=>$arr[1],
                    'equipName'=>$arr[2],
                    'count'=>$arr[3],
                    'points'=>$arr[4] ,
                    'code'=>$arr[5],
                ];
                $data[] = $row;
            }
        }
        CashMonitor::query()->insert($data);
        return ResponseUtil::success();

    }

    private function importActivelist($sheet){ //活动排期表

        ActiveRule::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                if (isset($arr[1]) && empty($arr[1])) continue;
                $row = [
                    'num'=>$arr[1],
                    'name'=>$arr[2],
                    'TypeId'=>$arr[3],
                    'rmark'=>$arr[4],
                    'serverGroup'=>$arr[5] ,
                    'ServerType'=>$arr[6],
                    'ServerList'=>$arr[7],
                    'TimeType'=>$arr[8] ,
                    'TimeOpen'=>$arr[9],
                    'TimeEnd'=>$arr[10],
                    'LoopType'=>$arr[11] ,
                    'LoopVal'=>$arr[12],
                    'LoopDayTimeLimitStart'=>$arr[13],
                    'LoopDayTimeLimitEnd'=>$arr[14] ,
                    'DayRefreshTime'=>$arr[15],
                    'UIInFuncId'=>$arr[16],
                    'UIInFuncIdParam'=>$arr[17],
                    'IsSysMsg'=>$arr[18] ,
                    'Rebirth'=>$arr[19],
                    'ExclusionAction'=>$arr[20],
                    'AdvanceDisplay'=>$arr[21],
                    'ContinuousDisplay'=>$arr[22],
                    'updated_at' => time()
                ];
                $data[] = $row;
            }
        }
        ActiveRule::query()->insert($data);
        return ResponseUtil::success();
    }


    private function importActiveCode($sheet) {
        $data = [];
        $batchSize = 500; // 每批插入的数量

        DB::beginTransaction(); // 开始事务
        try {
            foreach ($sheet as $key => $arr) {
                if (empty($arr) || $key <= 1) continue;

                $code = $arr[1] ?? null;
                if (empty($code)) continue; // 跳过该行数据

                $row = [
                    'code' => $arr[1],
                    'type' => $arr[2],
                    'channelid' => $arr[3],
                    'packageNo' => $arr[4],
                    'serverGroupid' => $arr[5],
                    'minlevel' => $arr[6],
                    'maxlevel' => $arr[7],
                    'starttime' => $arr[8],
                    'endtime' => $arr[9],
                    'rewardid' => $arr[10],
                    'getcount' => $arr[11]
                ];
                $data[] = $row;

                // 如果达到批次大小，执行插入
                if (count($data) >= $batchSize) {
                    ActiveCode::query()->insert($data);
                    $data = []; // 清空数据数组
                }
            }

            // 插入剩余的数据
            if (!empty($data)) {
                ActiveCode::query()->insert($data);
            }

            DB::commit(); // 提交事务

        } catch (\Exception $e) {
            DB::rollBack(); // 回滚事务
            MyLog::error('导入失败: ' . $e->getMessage());
            return ResponseUtil::error('导入失败');
        }

        return ResponseUtil::success();
    }

    private function importActivelistqd($sheet){ //活动排期表

        ActiveRuleQd::query()->truncate();
        $data = [];
        MyLog::info('活动排期表(渠道版)'.json_encode($sheet));
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                if (isset($arr[1]) && empty($arr[1])) continue;
                $row = [
                    'num'=>$arr[1],
                    'name'=>$arr[2],
                    'TypeId'=>$arr[3],
                    'rmark'=>$arr[4],
                    'serverGroup'=>$arr[5] ,
                    'ServerType'=>$arr[6],
                    'ServerList'=>$arr[7],
                    'TimeType'=>$arr[8] ,
                    'TimeOpen'=>$arr[9],
                    'TimeEnd'=>$arr[10],
                    'LoopType'=>$arr[11] ,
                    'LoopVal'=>$arr[12],
                    'LoopDayTimeLimitStart'=>$arr[13],
                    'LoopDayTimeLimitEnd'=>$arr[14] ,
                    'DayRefreshTime'=>$arr[15],
                    'UIInFuncId'=>$arr[16],
                    'UIInFuncIdParam'=>$arr[17],
                    'IsSysMsg'=>$arr[18] ,
                    'Rebirth'=>$arr[19],
                    'ExclusionAction'=>$arr[20],
                    'AdvanceDisplay'=>$arr[21],
                    'ContinuousDisplay'=>$arr[22],
                    'updated_at' => time()
                ];
                $data[] = $row;
            }
        }
        ActiveRuleQd::query()->insert($data);
        return ResponseUtil::success();

    }

    private function importActiveAtrrlist($sheet){ //活动排期表

        ActiveAtrr::query()->truncate();
        $data = [];
        MyLog::info('H-活动规则表'.json_encode($sheet));
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;

            if ($key>3){
                if (isset($arr[1]) && empty($arr[1])) continue;
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2]
                ];
                $data[] = $row;
            }
        }
        ActiveAtrr::query()->insert($data);
        return ResponseUtil::success();

    }

    private function importEquip($sheet) {
        Equip::query()->truncate();
        $data = [];
        foreach ($sheet as $key => $arr) {
            if (empty($arr) || $key <= 3) continue;

            // 检查 name 是否为 NULL
            if (isset($arr[2]) && !empty($arr[2])) {
                $row = [
                    'id' => $arr[1],
                    'name' => $arr[2],
                    'ItemQuality' => $arr[11],

                ];
                $data[] = $row;
            }
        }

        // 仅在有数据时执行插入
        if (!empty($data)) {
            Equip::query()->insert($data);
        }

        return ResponseUtil::success();
    }


    private function importEquipConfig($sheet) {
        EquipConfig::query()->truncate();
        $data = [];
        foreach ($sheet as $key => $arr) {
            if (empty($arr) || $key <= 3) continue;

            // 检查 name 是否为 NULL
            if (isset($arr[2]) && !empty($arr[2])) {
                $row = [
                    'id' => $arr[1],
                    'name' => $arr[2],
                    'level' => $arr[6],
                    'ItemQuality' => $arr[5],

                ];
                $data[] = $row;
            }
        }

        // 仅在有数据时执行插入
        if (!empty($data)) {
            EquipConfig::query()->insert($data);
        }

        return ResponseUtil::success();
    }
    private function importPetConfig($sheet) {
        PetConfig::query()->truncate();
        $data = [];
        foreach ($sheet as $key => $arr) {
            if (empty($arr) || $key <= 3) continue;

            // 检查 name 是否为 NULL
            if (isset($arr[2]) && !empty($arr[2])) {
                $row = [
                    'pid' => $arr[1],
                    'id' => $arr[2],
                    'name' => $arr[3],
                    'ItemQuality' => $arr[26],

                ];
                $data[] = $row;
            }
        }

        // 仅在有数据时执行插入
        if (!empty($data)) {
            PetConfig::query()->insert($data);
        }

        return ResponseUtil::success();
    }


    private function importMap($sheet){
        Map::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3){
                if (isset($arr[1]) && empty($arr[1])) continue;
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                ];
                $data[] = $row;
            }
        }
        Map::query()->insert($data);
        return ResponseUtil::success();
    }

    private function importOperType($sheet){
        OperType::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>0){
                $row = [
                    'id'=>$arr[0],
                    'name'=>$arr[2],
                ];
                $data[] = $row;
            }
        }
        OperType::query()->insert($data);
        return ResponseUtil::success();
    }

    private function importEquipAttr($sheet){
        EquipAttr::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3 && !empty($arr[1])){
                $row = [
                    'id'=>$arr[0],
                    'name'=>$arr[1],
                ];
                $data[] = $row;
            }
        }
        EquipAttr::query()->insert($data);
        return ResponseUtil::success();
    }
    private function importTask($sheet){ //任务信息配置表

        Task::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3 && !empty($arr[1]) && !empty($arr[3])){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                ];

                $data[] = $row;
            }
        }
        Task::query()->insert($data);
        return ResponseUtil::success();

    }
    private function importGemList($sheet){
        GemList::query()->truncate();
        $inserts = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>1){
                $row = [
                    'id'=>$arr[0], //物品ID
                    'name'=>$arr[1],
                    'title'=>$arr[2],
                    'Type'=>$arr[3],
                ];
                $inserts[] = $row;
            }
        }
        GemList::query()->insert($inserts);
        return ResponseUtil::success();
    }

    public function importGameGoods($sheet){
        //官方
        GameGoods::where('channeltype', 0)->delete();
        $inserts = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3 && !empty($arr[6]) ){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                    'detail'=>$arr[5],
                    'type'=>$arr[3],
                    'type_value'=>$arr[4],
                    'price_fee'=>$arr[6] * 100,
                    'Goodsid'=>$arr[8],
                    'quotaType'=>$arr[11],
                    'quotaNum'=>$arr[12],
                    'IOS'=>$arr[18],
                    'channeltype'=>0,
                ];
                $inserts[] = $row;
            }
        }
        GameGoods::query()->insert($inserts);
        return ResponseUtil::success();
    }

    private function importEquipNeedRecord($sheet)
    {
        $inserts = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>0){
                if ($arr[2] == 1){
                    $row = [
                        'equip_id'=>$arr[0],
                    ];
                    $inserts[] = $row;
                }
            }
        }
        EquipNeedRecord::query()->truncate();
        EquipNeedRecord::query()->insert($inserts);
        return ResponseUtil::success();
    }

    private function importEquipNeedMonitor($sheet)
    {
        $inserts = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>0){
                if ($arr[3] == 1){ //监控
                    $row = [
                        'equip_id'=>$arr[0],
                    ];
                    $inserts[] = $row;
                }
            }
        }
        EquipNeedMonitor::query()->truncate();
        EquipNeedMonitor::query()->insert($inserts);
        return ResponseUtil::success();
    }


    private function any($sheet){
        $array = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>0){
                if ($arr[3] == 1){
                    $array[] = $arr;
                }
            }
        }
        return ResponseUtil::success($array);
    }

    public function importGameGoodsQQ($sheet){
        //删除QQ对应配置表信息
        GameGoods::where('channeltype', 1)->delete();
        $inserts = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>3 && !empty($arr[6]) ){
                $row = [
                    'id'=>$arr[1],
                    'name'=>$arr[2],
                    'detail'=>$arr[5],
                    'type'=>$arr[3],
                    'type_value'=>$arr[4],
                    'price_fee'=>$arr[6] * 100,
                    'quotaType'=>$arr[11],
                    'quotaNum'=>$arr[12],
                    'channeltype'=>1,
                ];
                $inserts[] = $row;
            }
        }
        GameGoods::query()->insert($inserts);
        return ResponseUtil::success();
    }


    public function importGameGoodsbt($sheet, $type)
    {
        // 删除QQ对应配置表信息
        GameGoods::where('channeltype', $type)->delete();
        $inserts = [];
        MyLog::info('内购商城表导入');
        foreach ($sheet as $key => $arr) {
            if (empty($arr)) continue;

            if ($key > 3) {
                // 转换时间格式为时间戳
                MyLog::info('开始上架时间'.json_encode($arr[11]));
                MyLog::info('结束'.json_encode($arr[12]));

                $startTimeString = str_replace('*', '-', $arr[13]);
                $endTimeString = str_replace('*', '-', $arr[14]);

                // 转换时间格式为时间戳
                $startDateTime = DateTime::createFromFormat('Y-m-d-H-i-s', $startTimeString);
                $endDateTime = DateTime::createFromFormat('Y-m-d-H-i-s', $endTimeString);

                if ($startDateTime === false || $endDateTime === false) {
                    // 格式错误处理
                    continue; // 跳过当前行
                }

                $startTime = $startDateTime->getTimestamp();
                $endTime = $endDateTime->getTimestamp();

                $row = [
                       'id'=> $arr[3] !== '0' ? $arr[2] . $arr[3] : $arr[2],
                    'payid' => $arr[2],
                    'packageNo' => $arr[3],
                    'ProductCode' => $arr[4],
                    'name' => $arr[10],
                    'detail' => $arr[11],
                    'CNID' => $arr[5],
                    'GoogleID' => $arr[6],
                    'price_fee' => $arr[7],
                    'start_time' => $startTime,  // 转换后的时间戳
                    'end_time' => $endTime,      // 转换后的时间戳
                    'channeltype' => $type,
                ];

                $inserts[] = $row;
            }
        }
        MyLog::info('内购商城表导入数据'.json_encode($inserts));
        GameGoods::query()->insert($inserts);
        return ResponseUtil::success();
    }
    private function importGameMallGoods($sheet){
        GameMallGoodsconfg::query()->truncate();
        $data = [];
        foreach($sheet as $key=>$arr) {
            if (empty($arr)) continue;
            if ($key>4){
                $row = [
                    'id'=>$arr[1],
                    'shopmallId'=>$arr[2],
                    'name'=>$arr[3],
                ];
                $data[] = $row;
            }
        }
        GameMallGoodsconfg::query()->insert($data);
        return ResponseUtil::success();
    }

    private function push(){


    }


    private function check(){

    }

}

